CREATE TABLE [dbo].[wap_log_errores]
(
[fe_proceso] [dbo].[_fechahora] NOT NULL,
[cd_proceso] [dbo].[_codigo_largo] NOT NULL,
[nm_terminal] [dbo].[_nombre] NOT NULL,
[cd_operador] [dbo].[_nombre] NOT NULL,
[cd_error] [dbo].[_codigo] NOT NULL,
[de_error] [dbo].[_descripcion] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[wap_log_errores] ADD CONSTRAINT [PK_wap_log_errores] PRIMARY KEY NONCLUSTERED  ([fe_proceso], [cd_proceso], [nm_terminal]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [FK_cd_error] ON [dbo].[wap_log_errores] ([cd_error]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [FK_cd_operador] ON [dbo].[wap_log_errores] ([cd_operador]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [FK_nm_terminal] ON [dbo].[wap_log_errores] ([nm_terminal]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[wap_log_errores] ADD CONSTRAINT [FK_wap_log_errores_wap_errores] FOREIGN KEY ([cd_error]) REFERENCES [dbo].[wap_errores] ([cd_error]) ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[wap_log_errores] ADD CONSTRAINT [FK_wap_log_errores_wad_operadores] FOREIGN KEY ([cd_operador]) REFERENCES [dbo].[wad_operadores] ([cd_operador]) ON DELETE CASCADE ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[wap_log_errores] ADD CONSTRAINT [FK_wap_log_errores_wad_terminales] FOREIGN KEY ([nm_terminal]) REFERENCES [dbo].[wad_terminales] ([nm_terminal]) ON DELETE CASCADE
GO
EXEC sp_bindefault N'[dbo].[date]', N'[dbo].[wap_log_errores].[fe_proceso]'
GO
